package com.erclab.internal.xpresso.xml;

import com.erclab.internal.xpresso.exceptions.ReportColumnNotFound;
import com.erclab.internal.xpresso.reports.Report;
import com.erclab.internal.xpresso.reports.ReportResultSet;

public class SiteMapXmlHelper {

	public static void createUrlItems(Report report, StringBuffer xml) throws ReportColumnNotFound{
		ReportResultSet rrs = report.getReportResultSet();
		while(rrs.nextRow()){
			xml.append("\n<url>");
			// for (int i =0; i < rrs.getNumberOfColumns(); i++){
				xml.append("\n<loc>");
				xml.append(rrs.getRowValue("loc"));
				xml.append("</loc>");
				
				String lastMod = rrs.getRowValue("lastmod");
				if (lastMod != null &&! lastMod.equals("")){
					xml.append("\n<lastmod>");
					xml.append(lastMod);
					xml.append("</lastmod>");
				}
				
				String changeFreq = rrs.getRowValue("changeFreq");
				if (changeFreq != null &&! changeFreq.equals("")){
					xml.append("\n<changefreq>");
					xml.append(changeFreq);
					xml.append("</changefreq>");
				}
				
				String priority = rrs.getRowValue("priority");
				if (priority != null &&! priority.equals("")){
					xml.append("\n<priority>");
					xml.append(priority);
					xml.append("</priority>");
				}				
				
			//}
			xml.append("</url>\n");
		}
	}
	
}
